package cn.tedu.tmall.admin.content.controller;

import cn.tedu.tmall.admin.content.pojo.param.ArticleAddParam;
import cn.tedu.tmall.admin.content.service.IArticleService;
import cn.tedu.tmall.common.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文章管理端 Controller
 */
@Slf4j
@RequestMapping("/article")
@RestController
@Api(tags = "文章管理")
@Validated //@Valid 推荐用spring有增强
public class ArticleController {


    @Autowired
    private IArticleService articleService;

    /**
     * 添加文章
     * @return
     */
    @ApiOperation("添加文章")
    @PostMapping("/article/add")
    public JsonResult add(@Validated ArticleAddParam articleAddParam) {
        log.debug("添加文章接口,入参:{}",articleAddParam);
        articleService.addArticle(articleAddParam);
        JsonResult ok = JsonResult.ok();
        log.debug("添加文章接口,入参:{},出参:{}",articleAddParam,ok);
        return ok;
    }



    @ApiOperation("关闭显示-待完成")
    @PostMapping("/article/close")
    public JsonResult close(){
        return null;
    }

    @ApiOperation("开启显示-待完成")
    @PostMapping("/article/open")
    public JsonResult open(){
        return null;
    }

    @ApiOperation("删除文章-待完成")
    @PostMapping("/article/del")
    public JsonResult del(){
        return null;
    }

    @ApiOperation("更新文章-待完成")
    @PostMapping("/article/update")
    public JsonResult update(){
        return null;
    }

    @ApiOperation("文章列表-待完成")
    @PostMapping("/article/list")
    public JsonResult list(){
        return null;
    }
}
